﻿
Imports System.Data.SqlClient
Imports System.IO
Imports System
Imports System.Data
Imports System.Data.SqlClient.SqlConnection
Imports System.Windows.Forms

Public Class FmHD

    Private Sub BtKhachMoi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtKhachMoi.Click
        FmNewKH.Show()
    End Sub

    Private Sub BtThemHang_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtThemHang.Click
        FmThemHang.Show()
    End Sub

    Private Sub BtThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtThoat.Click
        Me.Close()
    End Sub

    Private Sub FmHD_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        XdKetNoi()

        Dim dieuphoi3 As New SqlDataAdapter("select a.MAHANG, b.TENHANG,a.SLBAN,a.DGBAN,(a.SLBAN * a.DGBAN ) as THANHTIEN from CHITIETHOADON a inner join HANGHOA b on a.MAHANG=b.MAHANG WHERE a.SOHD='" & TXTHD.Text & "'", KetNoi)
        Dim DTKH3 As New DataTable
        dieuphoi3.Fill(DTKH3)
        KetNoi.Close()
        BindingSource1.DataSource = DTKH3
        DataGridView1.DataSource = BindingSource1

        Dim dieuphoi As New SqlDataAdapter("select * from HOADON H inner join KHACHHANG K on H.MAKH =K.MAKH ", KetNoi)
        Dim DTKH As New DataTable
        dieuphoi.Fill(DTKH)
        KetNoi.Close()
        BindingSource1.DataSource = DTKH
        'DataGridView1.DataSource = BindingSource1

        TXTTKH.DataBindings.Add("Text", BindingSource1, "TENKH")
        TXTDC.DataBindings.Add("Text", BindingSource1, "DIACHI")
        TXTSDT.DataBindings.Add("Text", BindingSource1, "SDT")
        TXTSTK.DataBindings.Add("Text", BindingSource1, "SOTK")
        TXTHD.DataBindings.Add("Text", BindingSource1, "SOHD")
        TXTMST.DataBindings.Add("Text", BindingSource1, "MASOTHUE")
        TxTiLeVAT.DataBindings.Add("Text", BindingSource1, "VAT")



        Dim dieuphoi1 As New SqlDataAdapter("select * from HOADON H inner join KHACHHANG K on H.MAKH =K.MAKH ", KetNoi)
        DTKH = New DataTable
        dieuphoi.Fill(DTKH)
        
        CbMaKH.DataSource = DTKH
        CbMaKH.ValueMember = "MAKH"
        CbMaKH.DataBindings.Add("SelectedValue", BindingSource1, "MAKH")

        Dim dieuphoi2 As New SqlDataAdapter("select * from HOADON H inner join KHACHHANG K on H.MAKH =K.MAKH ", KetNoi)
        DTKH = New DataTable
        dieuphoi.Fill(DTKH)
        CbNgayLap.DataSource = DTKH
        CbNgayLap.ValueMember = "NGAYLAP"
        CbNgayLap.DataBindings.Add("SelectedValue", BindingSource1, "NGAYLAP")


    End Sub

    

    Private Sub CbMaKH_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CbMaKH.SelectedIndexChanged

    End Sub
End Class